home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ARASAN_S.ZIP / MOVEARR.H < prev    next >
C/C++ Source or Header  |  1994-07-03  |  2KB  |  95 lines

  1. // Copyright 1993 by Jon Dart.  All Rights Reserved.
  2.  
  3. #ifndef _MOVE_ARRAY_H
  4. #define _MOVE_ARRAY_H
  5.  
  6. #include "board.h"
  7. #include "emove.h"
  8. #include "array.h"
  9.  
  10. class Move_Array;
  11.  
  12. class Move_Record
  13. {
  14.      // holds info on a move made during the game or during a search
  15.      // operation.          
  16.  
  17.      public:
  18.  
  19.      Move_Record(const Board &board, const ExtendedMove &move);
  20.      // "board" is the board position after the move.
  21.          
  22.      Move_Record();
  23.      // create a null record.  Used only to initialize storage.
  24.      
  25.      ~Move_Record()
  26.      {
  27.      }
  28.      
  29.      const ExtendedMove &move() const
  30.      {
  31.           return my_move;
  32.      }
  33.      
  34.      const unsigned long hashcode() const
  35.      {
  36.          return my_hashcode;
  37.      }
  38.      
  39.      int operator == ( const Move_Record &l ) const;
  40.      int operator != ( const Move_Record &l ) const;
  41.      
  42.      private:
  43.          
  44.      ExtendedMove my_move;        
  45.      unsigned long my_hashcode;        
  46.      Board::CastleType my_caststat[2];
  47. };
  48.  
  49. class Move_Array : public Array<Move_Record>
  50. {
  51.      // Maintains a list of moves made in the game so far or in
  52.      // the search process.         
  53.          
  54.      public:         
  55.     
  56.      Move_Array();
  57.      // create a Move_Array.
  58.          
  59.      virtual ~Move_Array();         
  60.  
  61.      void add_move( const Board &board, const ExtendedMove &emove );
  62.      // add a move to the Move_Array. "board" is the position after the
  63.      // move is made.         
  64.          
  65.      void remove_move();
  66.      // remove the most recently added move to the Move_Array.
  67.          
  68.      // return the total number of half-moves in the game:
  69.      unsigned num_moves() const
  70.      {
  71.          return size();
  72.      }
  73.      
  74.      unsigned num_moves(const ColorType side);
  75.  
  76.      const ExtendedMove &move( const unsigned n );
  77.      // return the nth move in the Move_Array.  0 <= n <= num_moves - 1.
  78.     
  79.      int rep_count( const Board &board) const;
  80.      // returns a repetition count: how many times the board position
  81.      // has occurred in the game. 
  82.          
  83.      void clear();
  84.      // remove everything from the Move_Array
  85.          
  86.      private:
  87.          
  88.      enum {Rep_Table_Size = 128}; 
  89.          
  90.      int rep_table[Rep_Table_Size];
  91. };
  92.  
  93. #endif
  94.  
  95.